<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
using System;
using System.Data;
using <xsl:value-of select="Schema/@EntityNameSpace" />;
using <xsl:value-of select="Schema/@DataAccessNameSpace" />;

namespace <xsl:value-of select="Schema/@NameSpace" />
{
	/// <summary>
	/// <xsl:value-of select="Schema/@TableName" />Bus 的业务规则层代码。包含对数据的增、删、改、查。
	/// </summary>
	public class <xsl:value-of select="Schema/@TableName" />Bus
	{
		/// <summary>
		/// 添加一条记录
		/// </summary>
		public static void Add<xsl:value-of select="Schema/@TableName" />(<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" />)
		{
			<xsl:value-of select="Schema/@TableName" />Insert obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Insert();
			obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />);
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery();
		}

		/// <summary>
		/// 修改一条记录
		/// </summary>
		public static void Update<xsl:value-of select="Schema/@TableName" />(<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" />)
		{
			<xsl:value-of select="Schema/@TableName" />Update obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Update();
			obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />);
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery();
		}

		/// <summary>
		/// 删除一条记录
		/// </summary>
		public static void Delete<xsl:value-of select="Schema/@TableName" />(<xsl:for-each select="Schema/Columns[IS_PK='1']"><xsl:value-of select="concat(LANGUAGE_TYPE,' ',COLUMN_NAME)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>)
		{
			<xsl:value-of select="Schema/@TableName" />Delete obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Delete();<xsl:for-each select="Schema/Columns[IS_PK='1']">
			obj<xsl:value-of select="Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" />;</xsl:for-each>
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery();
		}

		/// <summary>
		/// 根据主键获取一条记录
		/// </summary>
		public static <xsl:value-of select="Schema/@TableName" /> Get<xsl:value-of select="Schema/@TableName" />(string ApplyID)
		{
			<xsl:value-of select="Schema/@TableName" />SelectByPk obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />SelectByPk();
			<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" /> = new <xsl:value-of select="Schema/@TableName" />();<xsl:for-each select="Schema/Columns[IS_PK='1']">
			obj<xsl:value-of select="Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" />;</xsl:for-each>
			obj<xsl:value-of select="Schema/@TableName" />.MetaDataTable = obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable();
			return obj<xsl:value-of select="Schema/@TableName" />;
		}

		/// <summary>
		/// 查询<xsl:value-of select="Schema/@TableName" />表的所有信息
		/// </summary>
		public static DataTable GetAll<xsl:value-of select="Schema/@TableName" />()
		{
			<xsl:value-of select="Schema/@TableName" />SelectAll obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />SelectAll();
			return obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable();
		}
	}
}</xsl:template>
</xsl:stylesheet>